<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Model;

/**
 * @property int $id ID
 * @property int $userid 用户ID
 * @property int $date 日期
 * @property int $chat_times 聊天发言次数
 * @property int $buy_project_times 购买爆料次数
 * @property int $online_minutes 在线分钟数
 * @property int $last_online_time 上次上报在线时间
 * @property int $view_article_times 阅读资讯次数
 * @property int $watch_live_minutes 观看直播分钟数
 * @property int $share_house_times 分享直播间次数
 * @property-read null|User $user 
 */
class UserTask extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'user_task';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'userid', 'date', 'chat_times', 'buy_project_times', 'online_minutes', 'last_online_time', 'view_article_times', 'watch_live_minutes', 'share_house_times'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'userid' => 'integer', 'date' => 'integer', 'chat_times' => 'integer', 'buy_project_times' => 'integer', 'online_minutes' => 'integer', 'last_online_time' => 'integer', 'view_article_times' => 'integer', 'watch_live_minutes' => 'integer', 'share_house_times' => 'integer'];

    public function user(){
        return $this->hasOne(User::class, 'id', 'userid')->select(['id', 'username', 'nickname', 'avatar', 'role_id']);
    }
}
